﻿using DevExpress.Mvvm.Gantt;
using System;
using System.Runtime.Serialization;

namespace DevWpfApp
{
    [DataContract]
    public class GanttTaskProxy
    {
        public GanttTaskProxy()
        {
        }
        private GanttTask _task;
        public GanttTask GanttTask
        {
            get
            {
                if (_task == null)
                {
                    _task = new GanttTask();
                }
                return _task;
            }
            set
            {
                _task = value;
            }
        }

        [DataMember]
        public DateTime? StartDate
        {
            get { return this.GanttTask.StartDate; }
            set { this.GanttTask.StartDate = value; }
        }

        [DataMember]
        public DateTime? FinishDate
        {
            get { return this.GanttTask.FinishDate; }
            set { this.GanttTask.FinishDate = value; }
        }

        [DataMember]
        public string Name
        {
            get { return this.GanttTask.Name; }
            set { this.GanttTask.Name = value; }
        }
        [DataMember]
        public DateTime? BaselineStartDate
        {
            get { return this.GanttTask.BaselineStartDate; }
            set { this.GanttTask.BaselineStartDate = value; }
        }

        [DataMember]
        public DateTime? BaselineFinishDate
        {
            get { return this.GanttTask.BaselineFinishDate; }
            set { this.GanttTask.BaselineFinishDate = value; }
        }

        [DataMember]
        public object ParentId
        {
            get { return this.GanttTask.ParentId; }
            set { this.GanttTask.ParentId = value; }
        }

        [DataMember]
        public object Id
        {
            get
            {
                return this.GanttTask.Id;
            }
            set { this.GanttTask.Id = value; }
        }

        [DataMember]
        public double Progress
        {
            get { return (int)this.GanttTask.Progress; }
            set { this.GanttTask.Progress = value; }
        }

        [DataMember]
        public GanttPredecessorLinkCollectionProxy Links
        {
            get
            {
                return new GanttPredecessorLinkCollectionProxy() { Links = _task.PredecessorLinks };
            }
            set
            {
                _task.PredecessorLinks = value.Links;
            }
        }
        [DataMember]
        public GanttResourceLinkCollectionProxy ResourceLinks
        {
            get
            {
                return new GanttResourceLinkCollectionProxy() { Links = _task.ResourceLinks };
            }
            set
            {
                _task.ResourceLinks = value.Links;
            }
        }
    }
}
